﻿<?php

function show ()
{ 
  global $features,$downloads,$news;
  if (isset($_GET["action"])) $myid=$_GET["action"]; else $myid="news";
  
    switch ($myid):

    case "info": $action="articles/info.php" ;break;
    case "features": echo $features;$action=-1;break;
    case "register": $action="reg.php" ;break;
    case "abyss": $action="articles/abyss.php" ;break;
    case "online": $action="articles/online.php" ;break;
    case "downloads": echo $downloads;$action=-1 ;break;
    case "administration" : $actiob="administration.php";break;
          
  endswitch;
  
  if (is_file($action)) { require $action;  
} 
 
}

function ListGoodIP($IP)
{
$GoodIPS = array
(
1 => "172.19.9.36",
2 => "localhost",
3 => "127.0.0.1",
4 => "::1",
5 => "172.19.67.66"
);
if(in_array($IP,$GoodIPS))
{
$h[FT]=1;
$h['ip']=$IP;
}
else
{
$h['FT']=0;
$h['ip']=$IP;
}
return $h;
}

//function that takes experience and returns level
function getLevel($data) {
   if ($data <= '0') {$exp = "0";}
   elseif ($data <= '1') {$exp = "1";}
   elseif ($data <= '2') {$exp = "2";}
   elseif ($data <= '3') {$exp = "3";}
   elseif ($data <= '4') {$exp = "4";}
   elseif ($data <= '5') {$exp = "5";}
   elseif ($data <= '6') {$exp = "6";}
   elseif ($data <= '7') {$exp = "7";}
   elseif ($data <= '8') {$exp = "8";}
   elseif ($data <= '9') {$exp = "9";}
   elseif ($data <= '10') {$exp = "10";}
   elseif ($data <= '483553') {$exp = "11";}
   elseif ($data <= '608161') {$exp = "12";}
   elseif ($data <= '825336') {$exp = "13";}
   elseif ($data <= '1091985') {$exp = "14";}
   elseif ($data <= '1418170') {$exp = "15";}
   elseif ($data <= '1810467') {$exp = "16";}
   elseif ($data <= '2332547') {$exp = "17";}
   elseif ($data <= '3002259') {$exp = "18";}
   elseif ($data <= '3820081') {$exp = "19";}
   elseif ($data <= '4820228') {$exp = "20";}
   elseif ($data <= '6115322') {$exp = "21";}
   elseif ($data <= '7725199') {$exp = "22";}
   elseif ($data <= '9727123') {$exp = "23";}
   elseif ($data <= '12075781') {$exp = "24";}
   elseif ($data <= '14762522') {$exp = "25";}
   elseif ($data <= '17879938') {$exp = "26";}
   elseif ($data <= '21482201') {$exp = "27";}
   elseif ($data <= '25494737') {$exp = "28";}
   elseif ($data <= '30171209') {$exp = "29";}
   elseif ($data <= '35999532') {$exp = "30";}
   elseif ($data <= '42807774') {$exp = "31";}
   elseif ($data <= '50898898') {$exp = "32";}
   elseif ($data <= '60588305') {$exp = "33";}
   elseif ($data <= '73257434') {$exp = "34";}
   elseif ($data <= '89381899') {$exp = "35";}
   elseif ($data <= '109123921') {$exp = "36";}
   elseif ($data <= '135145762') {$exp = "37";}
   elseif ($data <= '165081925') {$exp = "38";}
   elseif ($data <= '201229895') {$exp = "39";}
   elseif ($data <= '243367815') {$exp = "40";}
   elseif ($data <= '292723295') {$exp = "41";}
   elseif ($data <= '350683175') {$exp = "42";}
   elseif ($data <= '415055544') {$exp = "43";}
   elseif ($data <= '485437946') {$exp = "44";}
   elseif ($data <= '559304956') {$exp = "45";}
   elseif ($data <= '643833129') {$exp = "46";}
   elseif ($data <= '741341640') {$exp = "47";}
   elseif ($data <= '853768081') {$exp = "48";}
   elseif ($data <= '982677974') {$exp = "49";} 
   elseif ($data <= '11126779740') {$exp = "55";}
  
   else $exp="50+";
   
return $exp;
}

//function that takes player id and returns name of legion
function getLegion($data) {
$qa=mysql_query("SELECT l.name as name FROM legions as l LEFT JOIN legion_members as lm ON l.id=lm.legion_id WHERE lm.player_id='".$data."'");
if ($qa==NULL) $legion="---";
else
 {
  $row=mysql_fetch_array($qa);
  $legion=$row["name"];
 }


mysql_free_result($qa);

return $legion;
}

//function that takes race from db and returns more user-friendlyrace
function getRace($data) {

if ($data == 'ELYOS') {$race = "<font color=\"green\">Элиец</font>";}
elseif ($data == 'ASMODIANS') {$race = "<font color=\"gray\">Асмодианен</font>";}

return $race;
}

//function that takes class from db and returns more user-friendly class
function getClass($data) {

switch ($data) {
 case "WARRIOR": $player_class="Воин";break;
 case "GLADIATOR": $player_class="Гладиатор";break;
 case "TEMPLAR": $player_class="Страж";break;
 case "SCOUT": $player_class="Следопыт";break;
 case "ASSASSIN": $player_class="Убийцы";break;
 case "RANGER": $player_class="Стрелок";break;
 case "MAGE": $player_class="Маг";break;
 case "SORCERER": $player_class="Волщебник";break;
 case "SPIRIT_MASTER": $player_class="Заклинатель";break;
 case "PRIEST": $player_class="Прист";break;
 case "CLERIC": $player_class="Целитель";break;
 case "CHANTER": $player_class="Чантер";break;
}

return $player_class;
}

//function which takes world_id and return the name of zone
/* not completed yet*/
function getLocation($data) {

switch ($data) {
 case "110010000": $location="Элизиум";break;
 case "110020000": $location="Касинель";break;
 case "120010000": $location="Пандемониум";break;
 case "120020000": $location="Храм мархутан";break;
 case "210010000": $location="Фоэта";break;
 case "210020000": $location="Элтнен";break;
 case "210030000": $location="Бертон";break;
 case "210040000": $location="Интердика";break;
 case "210050000": $location="Ингиссон";break;
 case "210060000": $location="Теомбос";break;
 case "220010000": $location="Исхальген";break;
 case "220030000": $location="Альтград";break;
 case "220020000": $location="Морхейм";break;
 case "220040000": $location="Белуслан";break;
 case "220050000": $location="Брустохин";break;
 case "220070000": $location="Гелькмарос";break;
 case "300030000": $location="ТЛН";break;
 case "300040000": $location="ФТ";break;
 case "300050000": $location="Астерия";break;
 case "300060000": $location="Серное дерево";break;
 case "300070000": $location="Роах";break;
 case "300080000": $location="Легое крыло ";break;
 case "300090000": $location="Правое крыло";break;
 case "300100000": $location="Стальной плавник";break;
 case "300110000": $location="Дерадикон";break;
 case "300120000": $location="Ткисис";break;
 case "300130000": $location="Мирен";break;
 case "300140000": $location="Кротан";break;
 case "310110000": $location="Тео Лаба";break;
 case "320130000": $location="Адма";break;
 case "510010000": $location="Тюрьма";break;
 case "520010000": $location="Тюрьма";break;
 case "400010000": $location="Ресханта";break;
 case "310090000": $location="Инадарату";break;
 case "320050000": $location="Аракис";break;
 case "320080000": $location="Драупнир";break;
 case "320100000": $location="СО";break;
 case "320110000": $location="Алькуиа";break;
 case "310010000": $location="Асценсион";break;
 case "310020000": $location="Асценсион";break;
 
 default: $location="непонятно нихуя";break;
}
return $location;
}

function RulezOnServer($RulezRace){
if ($RulezRace=="ELYOS"){
$RaceRulez = 1;
} 
else {
$RaceRulez = 2;
}
if (RaceRulez == 1){
$PrintRace = "Элийцы";
}
else{
$PrintRace = "Асмодиане";
}
return $PrintRace;
}
function getPlayerss() {
$q = mysql_query("SELECT player_id, name, exp, race, all_kill, rank FROM abyss_rank LEFT JOIN players ON player_id = id WHERE ap>1 ORDER BY all_kill DESC LIMIT 100");
while($row = mysql_fetch_array($q))
{
$data["name"][]=$row["name"];
$data["race"][]=getRace($row["race"]);
$data["lvl"][]=getLevel($row["exp"]);
$data["legion"][]=getLegion($row["player_id"]);
$data["ap"][]=$row["ap"];
$data["kills"][]=$row["all_kill"];

} 
mysql_free_result($q);
return $data;

}

function getLegionss() {
$q = mysql_query("SELECT l.id as id, l.name as name, l.level as lvl, l.contribution_points as cp, lm.player_id as leader FROM legions as l LEFT JOIN legion_members as lm ON l.id=lm.legion_id WHERE lm.rank='BRIGADE_GENERAL' ORDER BY l.contribution_points DESC LIMIT 100");
while(@$row = mysql_fetch_array($q))
{
$data["names"][]=$row["name"];
$data["races"][]=getRace($a["race"]);
$data["cps"][]=$row["cp"];


} 
@mysql_free_result($q);
return @$data;
}

//функция вывода новостей, точнее получения массива новостей.
function GetNews(){
$q= mysql_query("SELECT * FROM site_news ORDER BY date & time");
while(@$row = mysql_fetch_array($q))
{
$newsdata[text][]=$row["text"];
$newsdata[author][]=$row["author"];
$newsdata[date][]=$row["date"];
$newsdata[name][]=$row["name"];
}
return $newsdata;
}

function ToUTF()
{
mysql_query('SET NAMES "utf8"');
}

function GetAdminData()
{
$q=mysql_query("SELECT * FROM site_acc");
while(@$row = mysql_fetch_array($q))
{
$acc_data[author] = $row["author"];
$acc_data[pass] = $row["pass"];
}
return $acc_data;
}

function GetShopCategor()
{
$q = mysql_query("SELECT * FROM aionshop_categories");
while(@$row = mysql_fetch_array($q))
{
$Categ['ID'][] = $row['categoryName'];
$Categ['NAME'][] = $row['categoryId'];
}
return $Categ;
}
function CountIDItems()
{
$q = mysql_query("SELECT itemUniqueId FROM aionshop_items ORDER BY -itemUniqueId");
while(@$row = mysql_fetch_array($q))
{
$lastID[] = $row['itemUniqueId'];
}
return $lastID;
}

?>



